package fr.vvins.core.user.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import fr.vvins.core.catalog.entity.Product;
import fr.vvins.core.catalog.entity.Vigneron;
import fr.vvins.core.dao.EntityImpl;

/**
 * UserComment entity
 */
@Entity

@Table(schema="vvins", name="VV_USER_COMMENT")
public class UserComment extends EntityImpl implements Serializable {

	private static final long serialVersionUID = 5892738146802839374L;
	@Id
	@GeneratedValue
	@Column(name="ID")
	private Integer id;
	
	@Basic
	@Column(name="DATE")
	private Date date;
	
	
	@ManyToOne
	@JoinColumn(name="USER_ID")
	private User user;
	
	@ManyToOne
	@JoinColumn(name="PRODUCT_ID")
	private Product product;
	
	@ManyToOne
	@JoinColumn(name="VIGNERON_ID")
	private Vigneron vigneron;
	
	@Basic
	@Column(name="COMMENT")
	private String comment;
	
	@Basic
	@Column(name="TITLE")
	private String title;
	
	@OneToMany(mappedBy="comment")
	private Set<UserRating> ratings;

	public UserComment() {
	}

	public UserComment(Integer id, User user, Product product, Vigneron vigneron,
			String comment) {
		super();
		this.id = id;
		this.user = user;
		this.product = product;
		this.vigneron = vigneron;
		this.comment = comment;
	}

	@Override
	public Integer getId() {
		return id;
	}

	@Override
	public void setId(Integer id) {
		this.id = id;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Vigneron getVigneron() {
		return vigneron;
	}

	public void setVigneron(Vigneron vigneron) {
		this.vigneron = vigneron;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public Set<UserRating> getRatings() {
		return ratings;
	}

	public void setRatings(Set<UserRating> ratings) {
		this.ratings = ratings;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	
}
